<template>
	<div class="">
		<!--滚动内容 start-->
		<el-scrollbar class="app-container-scroll-bar">
			
			<listTpml 
				ref="listTpml"
			    :data="pageData"
				@onCommand="listCommand"
			></listTpml>
			
     </el-scrollbar>
    <!--滚动内容 end -->
		
		<!--弹窗内容 start-->
		<div class="app-output-window">
			<addZDDialog ref="addZDDialog" @addSucess="refresh"></addZDDialog>
		</div>
		<!--弹窗内容 end-->
		
	</div>
</template>

<script>
import addZDDialog from "@/view/components/dialog/addZDDialog";
import listTpml from "@/view/components/listTmpl"
import { apiUrls, getAllAcDict,deleteGroup } from "@/service/swagger/AcDictController";

export default {
	components: {
		listTpml,
		addZDDialog
	},
	data() {
		return {
			pageData: {
				pageTitle: "字典管理",
				// 过滤设置
				filterOption: [
					{
						label: "类型",
						paramsName: "type",
						defaultValue: "01",
						componentsName: "dictionaryType",
					}
				],
				//列表tabel 设置
				listOption: {
					listBtns: [{
						label: "新建配置项信息",
						iconfont: "icon-folder-add",
						commandName: "addDeploy"
					}],
					// 列表api
					listApi: {
						serviceFN: getAllAcDict,
						params: {
							//type: '01'
						}
					},
					//表头设置
					header: [
						{
							label: "ID",
							width: "",
							propName: "id",
							align: "left",
						},
						{
							label: "类型",
							width: "",
							propName: "group"
						},
						{
							label: "健名",
							width: "",
							propName: "code"
						},
						{
							label: "名称",
							width: "",
							propName: "name"
						},
						{
							label: "值",
							width: "",
							propName: "value"
						},
						{
							label: "备注",
							width: "",
							propName: "description"
						},
						{
							label: "操作",
							width: "",
							btns: [{
								label: "修改",
								commandName: "updateZD",
							}, {
								label: "删除",
								commandName: "deleteZD",
							}],
							btnGroups: []
						}]
				}
			}
		}
	},
	methods: {
		listCommand(command, row, index) {
			// console.log("列表进行了操作：", command,row,index );
			if (command && this[command]) {
				this[command](row, index);
			}
		},
		refresh() {
			this.$refs.listTpml.search();
		},
		addDeploy(row, index) {
			this.$refs.addZDDialog.open()
		},
		updateZD(row, index) {
			console.log("修改字典", row, index);
			this.$refs.addZDDialog.init(row).open()
		},
		deleteZD(row, index) {
		   this.$confirm("此操作将永久删除该字典,是否继续?","提示",{
			   confirmButtonText:"确定",
			   cancelButtonText:"取消",
			   type:"waring"
		   }).then(() =>{
			   deleteGroup({id:row.id}).then(ret => {
				   if(ret.code === 0){
					   this.$message({message:"删除成功!",type:"success"})
                       this.refresh();  
				   }else {
					   this.$message({message:"删除失败!",type:"error"})
				   }
			   })
		   })
		},
	}
}
</script>

<style>
</style>